//
//  NSAttributedString+Additions.m
//  Common
//
//  Created by shiqing guo on 2018/9/10.
//  Copyright © 2018年 www.bitkinetic.com. All rights reserved.
//

#import "NSAttributedString+Additions.h"


@implementation NSAttributedString (Additions)

- (instancetype)initWithString:(NSString *)str font:(UIFont *)font lineSpace:(CGFloat)lSpace wordSpace:(CGFloat)wSpace
{
    if (nil == str) return nil;
    
    NSMutableParagraphStyle *paraStyle = [[NSMutableParagraphStyle alloc] init];
    paraStyle.lineBreakMode = NSLineBreakByCharWrapping;
    paraStyle.alignment = NSTextAlignmentLeft;
    paraStyle.lineSpacing = lSpace; //设置行间距
    paraStyle.hyphenationFactor = 1.0; // 连字符属性
    paraStyle.firstLineHeadIndent = 0.0;
    paraStyle.paragraphSpacingBefore = 0.0; // 段首行空白空间
    paraStyle.headIndent = 0;
    paraStyle.tailIndent = 0;
//    paraStyle.paragraphSpacing = font.pointSize; // 新增段落高度
    paraStyle.alignment = NSTextAlignmentJustified;
    NSDictionary *dic = @{NSFontAttributeName:font, NSParagraphStyleAttributeName:paraStyle, NSKernAttributeName:@(wSpace)};
    
    if (self = [[NSAttributedString alloc] initWithString:str attributes:dic]) {
    }
    return self;
}
@end

